<template>
    <div class="pie">
        <div :id="'kline' + cageId" :style="styles"></div>
    </div>
</template>

<script>
import echarts from 'echarts';
export default {
  data () {
    return {
      cageId: parseInt(Math.random() * 100000)
    };
  },
  mounted () {
    this.drawLine();
  },
  props: {
    // 样式
    styles: Object,
    // 参数数据
    paramsData: Array,
    // 提示数据
    xData: Array,
    // 标题
    title: String
  },
  methods: {
    drawLine () {
      let that = this;
      console.log(that.paramsData);
      // 基于准备好的dom，初始化echarts实例
      let myChart = echarts.init(document.getElementById('kline' + that.cageId));
      // 绘制图表
      myChart.setOption({
        title: {
          text: '动态数据 + 时间坐标轴'
        },
        tooltip: {
          trigger: 'axis',
          formatter: function (params) {
            return params[0].name + '：' + params[0].value[1];
          },
          axisPointer: {
            animation: false
          }
        },
        xAxis: {
          type: 'time',
          splitLine: {
            show: false
          }
        },
        yAxis: {
          type: 'value',
          boundaryGap: [0, '100%'],
          splitLine: {
            show: false
          }
        },
        series: [{
          name: '模拟数据',
          type: 'line',
          showSymbol: false,
          hoverAnimation: false,
          data: that.paramsData
        }]
      });
    }
  }
};
</script>


<style lang="stylus" scoped>

</style>
